<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>自动触发事件</title>
    <style>
        div {
            width: 100px;
            height: 100px;
            background-color: pink;
        }
    </style>
    <script src="jquery.min.js"></script>
</head>

<body>
    <div></div>
    <script>
        $(function() {
            $('div').on('click', function() {
                alert(1);
            });
            // 自动触发事件
            // 1.元素.事件()
            // $('div').click();
            // 2.元素.trigger("type")
            // $('div').trigger('click');
            // 3.元素.triggerHandler("type")
            $('div').triggerHandler('click')
        });
    </script>
</body>

</html>